<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //   var obj = { name: "张三", age: 18, height: "178cm" };
      //   for (var key in obj) {
      //     console.log(key);
      //     console.log(obj[key]);
      //   }
      // 小练习：  var obj = {name:"张三",age:20,fn:function(){console.log(123)}};
      // 循环判断 如果是 一个函数那么就执行函数；
      var obj = {
        name: "张三",
        age: 20,
        fn: function () {
          console.log(123);
        },
      };
      for (var key in obj) {
        if (typeof obj[key] == "function") {
          console.log(key);
          console.log(obj[key]);
          obj[key]();
        }
      }
    </script>
  </body>
</html>
